package org.zhang.shortlink.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.zhang.shortlink.common.convention.result.Result;
import org.zhang.shortlink.common.convention.result.Results;
import org.zhang.shortlink.project.dto.req.RecycleBinSaveDTO;
import org.zhang.shortlink.project.dto.req.ShortLinkPageDTO;
import org.zhang.shortlink.project.dto.resp.ShortLinkPageVO;
import org.zhang.shortlink.project.service.RecycleBinService;

/**
 * @author: 张嘉庆
 * @date: 2024/4/21 20:25
 * @description: 回收站接口控制器
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    /**
     * 保存回收站
     */
    @PostMapping("/api/short-link/v1/recycle-bin/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveDTO requestParam) {
        recycleBinService.saveRecycleBin(requestParam);
        return Results.success();
    }

    /**
     * 分页回收站列表
     */
    @GetMapping("/api/short-link/v1/recycle-bin/page")
    public Result<IPage<ShortLinkPageVO>> pageRecycleBinShortLink(ShortLinkPageDTO requestParam) {
        return Results.success(recycleBinService.pageRecycleBinShortLink(requestParam));
    }
}
